<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/system/admin/header.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>"><!-- jsp文件头和头部 -->
    <%@ include file="/WEB-INF/jsp/system/admin/top.jsp" %>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <hr class="layui-bg-blue">
                <table class="layui-table" lay-data="{height: '500', url:'${objectNameLower}/list.do',page:true,limit:20 ,skin:'line', even:false, size:'lg'}" lay-filter="demoEvent">
                    <thead>
                    <!-- 开始循环 -->
                                    <tr>

                                    <#list fieldList as var>
                                        <th lay-data="{field:'${var[0]}', width:120,sort: true}">${var[2]}</th>
                                    </#list>
                                    </tr>
                    </thead>
                </table>

            </div>
            <!-- PAGE CONTENT ENDS HERE -->
        </div><!--/row-->

    </div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->

<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
    <i class="icon-double-angle-up icon-only"></i>
</a>

<script type="text/javascript">
    layui.use('table', function(){
        var table = layui.table;

    });
    $(top.hangge());
    //检索
    function search() {
        top.jzts();
        $("#Form").submit();
    }
    //新增
    function add() {
        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title = "新增";
        diag.URL = '<%=basePath%>${objectNameLower}/goAdd.do';
        diag.Width = 450;
        diag.Height = 355;
        diag.CancelEvent = function () { //关闭事件
            if (diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none') {
                if ('${r"${page.currentPage}"}' == '0') {
                    top.jzts();
                    setTimeout("self.location.reload()", 100);
                } else {
                    nextPage(${r"${page.currentPage}"});
                }
            }
            diag.close();
        };
        diag.show();
    }
    //删除
    function del(Id) {
        bootbox.confirm("确定要删除吗?", function (result) {
            if (result) {
                top.jzts();
                var url = "<%=basePath%>${objectNameLower}/delete.do?${objectNameUpper}_ID=" + Id + "&tm=" + new Date().getTime();
                $.get(url, function (data) {
                    nextPage(${r"${page.currentPage}"});
                });
            }
        });
    }
    //修改
    function edit(Id) {
        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title = "编辑";
        diag.URL = '<%=basePath%>${objectNameLower}/goEdit.do?${objectNameUpper}_ID=' + Id;
        diag.Width = 450;
        diag.Height = 355;
        diag.CancelEvent = function () { //关闭事件
            if (diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none') {
                nextPage(${r"${page.currentPage}"});
            }
            diag.close();
        };
        diag.show();
    }
</script>
<script type="text/javascript">
    $(function () {
        //下拉框
        $(".chzn-select").chosen();
        $(".chzn-select-deselect").chosen({allow_single_deselect: true});
        //日期框
        $('.date-picker').datepicker();
        //复选框
        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                    .each(function () {
                        this.checked = that.checked;
                        $(this).closest('tr').toggleClass('selected');
                    });
        });
    });
    //批量操作
    function makeAll(msg) {
        bootbox.confirm(msg, function (result) {
            if (result) {
                var str = '';
                for (var i = 0; i < document.getElementsByName('ids').length; i++) {
                    if (document.getElementsByName('ids')[i].checked) {
                        if (str == '') str += document.getElementsByName('ids')[i].value;
                        else str += ',' + document.getElementsByName('ids')[i].value;
                    }
                }
                if (str == '') {
                    bootbox.dialog("您没有选择任何内容!",
                            [
                                {
                                    "label": "关闭",
                                    "class": "btn-small btn-success",
                                    "callback": function () {
                                        //Example.show("great success");
                                    }
                                }
                            ]
                    );

                    $("#zcheckbox").tips({
                        side: 3,
                        msg: '点这里全选',
                        bg: '#AE81FF',
                        time: 8
                    });

                    return;
                } else {
                    if (msg == '确定要删除选中的数据吗?') {
                        top.jzts();
                        $.ajax({
                            type: "POST",
                            url: '<%=basePath%>${objectNameLower}/deleteAll.do?tm=' + new Date().getTime(),
                            data: {DATA_IDS: str},
                            dataType: 'json',
                            //beforeSend: validateData,
                            cache: false,
                            success: function (data) {
                                $.each(data.list, function (i, list) {
                                    nextPage(${r"${page.currentPage}"});
                                });
                            }
                        });
                    }
                }
            }
        });
    }
    //导出excel
    function toExcel() {
        window.location.href = '<%=basePath%>${objectNameLower}/excel.do';
    }
</script>

</body>
</html>

